import sqlite3

# 连接到数据库
conn = sqlite3.connect("cloud_clip.db")
cursor = conn.cursor()

# 创建表
# 平台、地区、粉丝量、价格规则
cursor.executescript("""
CREATE TABLE IF NOT EXISTS Platforms (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS Regions (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS FanLevels (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS PricingRules (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    platform_id INTEGER NOT NULL,
    region_id INTEGER NOT NULL,
    fan_level_id INTEGER NOT NULL,
    min_price REAL NOT NULL,
    max_price REAL NOT NULL,
    FOREIGN KEY (platform_id) REFERENCES Platforms(id),
    FOREIGN KEY (region_id) REFERENCES Regions(id),
    FOREIGN KEY (fan_level_id) REFERENCES FanLevels(id)
);
""")

print("创建表成功.")

# 提交并关闭连接
conn.commit()
conn.close()
